package com.dwxt.community.service.supervisor;

import com.dwxt.common.base.BaseResult;
import com.dwxt.common.util.PartyUtil;
import com.dwxt.community.aiequipment.aibin.entity.TrashCan;
import com.dwxt.community.aiequipment.aibin.entity.TrashInner;
import com.dwxt.community.aiequipment.aibin.entity.vo.TrashInnerVo;
import com.dwxt.community.dao.SupervisorUserMapper;
import com.dwxt.community.dao.TrashInnerMapper;
import com.dwxt.community.entity.enumerate.StateConstant;
import com.dwxt.community.entity.vo.SupervisorUserVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TrashInnerService {

    @Autowired
    private TrashInnerMapper trashInnerMapper;
    @Autowired
    private SupervisorUserMapper supervisorUserMapper;

    /**
     * 获取所有的内桶
     * @param pageNum
     * @param pageSize
     * @return
     */
    public PageInfo selectAll(Integer pageNum, Integer pageSize) {
        String currentUserId = PartyUtil.getCurrentUserId();
        SupervisorUserVo suv = supervisorUserMapper.selectDetailByPrimaryKey(currentUserId);
        PageInfo pageInfo = new PageInfo();
        PageHelper.startPage(pageNum, pageSize);
        if (StateConstant.XUN_JIAN_YUAN.getMsg().equals(suv.getSupervisorRole().getName())) {
            pageInfo = new PageInfo(trashInnerMapper.selectBySupervisorUserXjy(PartyUtil.getCurrentUserId()));
        } else if (StateConstant.DU_DAO_YUAN.getMsg().equals(suv.getSupervisorRole().getName())) {
            pageInfo = new PageInfo(trashInnerMapper.selectBySupervisorUserDdy(currentUserId));
        }
        return pageInfo;
    }
}
